import Vue from 'vue';
import Cookie from 'js-cookie';

Vue.prototype.$utils = {
  loginStatus() {
    let userToken = Cookie.get('rabbit_token'),
      userIdentify = Cookie.get('rabbit_userID');

    return Boolean(userToken) && Boolean(userIdentify);
  },
  userType() {
    let isLogin = this.loginStatus(),
      userData = Cookie.get('rabbit_userID');

    return new Promise((resolve, reject) => {
      isLogin ? resolve(JSON.parse(userData)) : reject();
    });
  }
}